/* =========================================================
   WHERE CAN WE BUILD?
   Black and white only: the same ink and paper as the rest of the app.
   Yes = solid, Grey = hatched, No = outline, Not valid = crossed out.
   Used inside the Where row on the Systems page.
   ========================================================= */

.wcb { margin: 1.5rem 0 4rem; }

/* app.css styles every button in the app; these start clean */
.wcb button,
.wcb .cell-detail button {
    font: inherit;
    color: inherit;
    background: none;
    border: none;
    padding: 0;
    letter-spacing: normal;
    text-align: left;
    cursor: pointer;
}

.wcb-steps { display: flex; flex-wrap: wrap; gap: 0.6rem 1.6rem; list-style: none; font-size: 0.7rem; letter-spacing: 0.18rem; text-transform: uppercase; }
.wcb-steps li { opacity: 0.35; transition: opacity 0.4s ease; }
.wcb-steps li.on { opacity: 1; }
.wcb-steps b {
    display: inline-grid;
    place-items: center;
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.4rem;
    border: 1px solid currentColor;
    border-radius: 50%;
    font-weight: 500;
    letter-spacing: 0;
}

.wcb h2 { margin-top: 1.4rem; margin-bottom: 0.6rem; }
.wcb-lead { font-size: 1rem; line-height: 1.5; }

.wcb .wcb-link { text-decoration: underline; text-underline-offset: 0.25rem; }

.wcb-surfaces { list-style: none; margin-top: 0.8rem; max-width: 720px; font-size: 0.88rem; line-height: 1.5; }
.wcb-surfaces[hidden] { display: none; }
.wcb-surfaces li { padding: 0.35rem 0; border-top: 1px solid var(--line); }
.wcb-surfaces b { font-weight: 500; }


/* ---------- step 1: three doors ---------- */

.doors { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 1rem; margin-top: 2rem; }

.wcb .door {
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
    min-height: 17rem;
    padding: 1.6rem;
    border-top: 3px solid var(--line);
    background: rgba(42, 40, 36, 0.04);
    color: var(--ink);
    transition: transform 0.35s ease, background 0.35s ease, color 0.35s ease, opacity 0.35s ease;
}
.wcb .door:hover { transform: translateY(-4px); background: rgba(42, 40, 36, 0.09); }
.wcb .door:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }
.wcb .door.on { background: var(--ink); color: var(--paper); border-top-color: var(--ink); }
.doors.picked .door:not(.on) { opacity: 0.4; }

.door-pic { width: 6rem; height: 5rem; flex-shrink: 0; stroke-width: 1.5; margin-bottom: 1.6rem; }
.door b { font-family: 'Cinzel', serif; font-size: 1.5rem; letter-spacing: 0.08rem; }
.door-line { font-size: 0.88rem; line-height: 1.45; opacity: 0.85; }
.door-eg { font-family: 'Fraunces', serif; font-style: italic; font-size: 1rem; }

.wcb .wcb-btn {
    display: inline-block;
    margin-top: 1.4rem;
    padding: 0.85rem 1.5rem;
    border: 1px solid var(--ink);
    font-size: 0.75rem;
    letter-spacing: 0.15rem;
    text-transform: uppercase;
}



/* ---------- virtual: screen only, then back ---------- */

.wcb-virtual { margin-top: 2.5rem; padding: 3rem 1rem; text-align: center; border: 1px solid var(--ink); }
.wcb-virtual[hidden] { display: none; }

.screen-only { position: relative; width: min(260px, 70vw); margin: 0 auto; }
.screen-only svg { display: block; width: 100%; height: auto; fill: none; stroke: var(--ink); stroke-width: 2; }
.screen-only .scan {
    position: absolute;
    left: 8.3%;
    top: 6.2%;
    width: 83.4%;
    height: 75%;
    background: repeating-linear-gradient(to bottom, rgba(42, 40, 36, 0.16) 0 1px, transparent 1px 4px);
    overflow: hidden;
}
.screen-only .scan::after {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    height: 18%;
    background: linear-gradient(to bottom, transparent, rgba(42, 40, 36, 0.22), transparent);
    animation: wcb-scan 2.4s linear infinite;
}

.glitch {
    position: relative;
    display: inline-block;
    margin-top: 1.6rem;
    font-family: 'Cinzel', serif;
    font-size: clamp(1.6rem, 3vw, 2.4rem);
    letter-spacing: 0.15rem;
}
.glitch::before,
.glitch::after {
    content: attr(data-text);
    position: absolute;
    inset: 0;
    opacity: 0;
}
.play .glitch::before { animation: wcb-glitch-a 0.9s steps(2) 3; }
.play .glitch::after { animation: wcb-glitch-b 0.9s steps(2) 3; }
.play .glitch-line { animation: wcb-flicker 0.9s steps(2) 3; }

.wcb-stop { max-width: 460px; margin: 0.8rem auto 0; font-family: 'Fraunces', serif; font-style: italic; font-size: 1.1rem; line-height: 1.5; }

@keyframes wcb-scan { from { top: -18%; } to { top: 100%; } }
@keyframes wcb-glitch-a {
    0% { opacity: 0.55; transform: translate(-3px, 1px); clip-path: inset(10% 0 55% 0); }
    50% { opacity: 0.55; transform: translate(3px, -1px); clip-path: inset(60% 0 8% 0); }
    100% { opacity: 0; transform: none; }
}
@keyframes wcb-glitch-b {
    0% { opacity: 0.4; transform: translate(3px, 0); clip-path: inset(45% 0 30% 0); }
    50% { opacity: 0.4; transform: translate(-2px, 1px); clip-path: inset(5% 0 75% 0); }
    100% { opacity: 0; transform: none; }
}
@keyframes wcb-flicker { 0% { opacity: 0.2; } 50% { opacity: 1; } 100% { opacity: 0.6; } }


/* ---------- step 2 and 3: bar, chips, counter ---------- */

.wcb-world { margin-top: 3rem; }
.wcb-world[hidden] { display: none; }

.wcb-bar {
    position: sticky;
    top: 4.6rem;
    z-index: 5;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.7rem 1.2rem;
    margin-top: 1.2rem;
    padding: 0.7rem 0;
    background: var(--paper);
    box-shadow: 0 0 0 100vmax var(--paper);     /* paints the full width */
    clip-path: inset(-1px -100vmax 0 -100vmax);
    border-bottom: 1px solid var(--line);
}

.wcb-switch { display: inline-flex; }
.wcb .wcb-switch button { padding: 0.5rem 1rem; border: 1px solid var(--ink); font-size: 0.78rem; letter-spacing: 0.06rem; }
.wcb .wcb-switch button + button { border-left: none; }
.wcb .wcb-switch button.on { background: var(--ink); color: var(--paper); }

.wcb-chips { display: flex; flex-wrap: wrap; gap: 0.45rem; }
.wcb .chip {
    display: inline-flex;
    align-items: center;
    padding: 0.45rem 0.9rem;
    border: 1px solid var(--ink);
    border-radius: 999px;
    font-size: 0.8rem;
    transition: background 0.25s ease, color 0.25s ease;
}
.wcb .chip.on { background: var(--ink); color: var(--paper); }

.wcb-count {
    display: block;
    min-width: 8.5rem;
    margin-left: auto;
    padding: 1.3rem 1.2rem;
    border: 1px dashed var(--ink);
}
.wcb-count span { display: block; font-size: 0.62rem; letter-spacing: 0.13rem; text-transform: uppercase; opacity: 0.65; }
.wcb-count b { display: block; margin-top: 0.4rem; font-family: 'Cinzel', serif; font-size: 1.5rem; font-weight: 700; letter-spacing: 0.06rem; }

/* the rule marks: same idea as the Given / Assumed / Derived squares */
.mk {
    display: inline-block;
    flex-shrink: 0;
    width: 0.8rem;
    height: 0.8rem;
    margin-right: 0.45rem;
    border: 1px solid currentColor;
    vertical-align: -0.1rem;
}
.mk.yes { background: currentColor; }
.mk.grey { background: repeating-linear-gradient(135deg, currentColor 0 1px, transparent 1px 4px); }
.mk.notvalid {
    background:
        linear-gradient(to top right, transparent calc(50% - 0.6px), currentColor calc(50% - 0.6px) calc(50% + 0.6px), transparent calc(50% + 0.6px)),
        linear-gradient(to bottom right, transparent calc(50% - 0.6px), currentColor calc(50% - 0.6px) calc(50% + 0.6px), transparent calc(50% + 0.6px));
}


/* ---------- the stage: one set of cells, two layouts ---------- */

.wcb-scroll { margin-top: 1.4rem; overflow-x: auto; overflow-y: hidden; -webkit-overflow-scrolling: touch; }

.wcb-stage {
    position: relative;
    margin: 0 auto;
    background: var(--paper);
    transition: width 0.8s cubic-bezier(0.6, 0, 0.2, 1), height 0.8s cubic-bezier(0.6, 0, 0.2, 1);
}

.wcb-bg { position: absolute; inset: 0; width: 100%; height: 100%; transition: opacity 0.6s ease; }
.wcb-stage.grid .wcb-bg { opacity: 0; }

.wcb-bg .ink { fill: var(--ink); }
.wcb-bg .stop-ink { stop-color: var(--ink); }
.wcb-bg .stop-paper { stop-color: var(--paper); }
.wcb-bg .star { fill: var(--paper); opacity: 0.7; }
.wcb-bg .planet { fill: rgba(239, 236, 229, 0.1); stroke: var(--paper); stroke-width: 1.5; }
.wcb-bg .tube { fill: var(--ink); stroke: var(--paper); stroke-width: 1.5; stroke-dasharray: 6 6; }
.wcb-bg .cruise { fill: none; stroke: var(--paper); stroke-width: 2; stroke-dasharray: 10 8; }
.wcb-bg .edge { fill: none; stroke: var(--ink); stroke-width: 2.5; }
.wcb-bg .wave { fill: none; stroke: var(--paper); stroke-opacity: 0.3; stroke-width: 1.2; }
.wcb-bg .grain { fill: var(--paper); opacity: 0.28; }
.wcb-bg .stars { transition: transform 0.1s linear; }

.wcb-bg .lbl { font-family: 'Work Sans', sans-serif; font-size: 24px; font-weight: 500; letter-spacing: 5px; text-transform: uppercase; fill: var(--ink); }
.wcb-bg .lbl.small { font-size: 18px; letter-spacing: 3px; }
.wcb-bg .lbl.light { fill: var(--paper); }
.wcb-bg .lbl.halo { fill: var(--paper); paint-order: stroke; stroke: var(--ink); stroke-width: 4px; }
.wcb-bg .lbl.end { text-anchor: end; }

.wcb-bg .layer { opacity: 0; transition: opacity 0.9s ease; }
.wcb-bg .layer.in { opacity: 1; }

/* layer names in the section */
.slabel {
    position: absolute;
    font-size: 0.72rem;
    font-weight: 500;
    letter-spacing: 0.2rem;
    text-transform: uppercase;
    color: var(--ink);
    pointer-events: none;
    white-space: nowrap;
    transition: opacity 0.5s ease;
}
.slabel.light { color: var(--paper); }
.wcb-stage.grid .slabel { opacity: 0; }

/* grid headings, only in the grid */
.glabel {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.5s ease;
}
.glabel.col { top: 0; height: 8%; font-family: 'Cinzel', serif; font-size: 1.05rem; letter-spacing: 0.08rem; }
.glabel.row { left: 0; width: 11%; font-size: 0.72rem; letter-spacing: 0.15rem; text-transform: uppercase; }
.wcb-stage.grid .glabel { opacity: 1; transition-delay: 0.4s; }

/* a place */
.wcb .cell {
    position: absolute;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.35rem;
    text-align: center;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--ink);
    opacity: 0;
    transform: translateY(16px);
    transition:
        left 0.8s cubic-bezier(0.6, 0, 0.2, 1), top 0.8s cubic-bezier(0.6, 0, 0.2, 1),
        width 0.8s cubic-bezier(0.6, 0, 0.2, 1), height 0.8s cubic-bezier(0.6, 0, 0.2, 1),
        opacity 0.6s ease, transform 0.4s ease, background 0.4s ease, color 0.4s ease, box-shadow 0.3s ease;
}
.wcb .cell.in { opacity: 1; transform: none; }
.wcb .cell.in:hover { transform: translateY(-3px); box-shadow: 0 8px 18px rgba(42, 40, 36, 0.28); }
.wcb .cell:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; z-index: 2; }

.cell .pic { flex: 1 1 auto; width: 100%; min-height: 0; max-height: 4.4rem; stroke-width: 1.6; }
.cell-name { font-size: 0.74rem; font-weight: 500; letter-spacing: 0.03rem; white-space: nowrap; }
.cell-ex { display: none; font-size: 0.72rem; line-height: 1.3; opacity: 0.85; }
.cell-rule { display: inline-flex; align-items: center; font-size: 0.66rem; }
.cell-note { display: none; font-family: 'Fraunces', serif; font-style: italic; font-size: 0.66rem; }

/* Air On is not valid: quiet in the section, normal in the grid */
.wcb .wcb-stage.section .cell.in.r-notvalid { opacity: 0.35; }
.wcb-stage.section .cell.r-notvalid .pic,
.wcb-stage.section .cell.r-notvalid .cell-note { display: none; }

/* Real: not built today */
.wcb .cell.in.unbuilt { opacity: 0.45; }
.cell.unbuilt .cell-note { display: block; }
.cell.unbuilt .cell-rule { display: none; }

/* the filter: lit ones stay, the rest go quiet */
.wcb .cell.in.dim { opacity: 0.12; }
.wcb .cell.in.lit { opacity: 1; box-shadow: 0 0 0 3px var(--paper), 0 0 0 4px var(--ink); }

/* grid: the cell itself shows the rule */
.wcb-stage.grid .cell { padding: 0.6rem; }
.wcb-stage.grid .cell-ex { display: block; }
.wcb-stage.grid .cell .pic { max-height: 3.4rem; }
.wcb .wcb-stage.grid .cell.r-yes { background: var(--ink); color: var(--paper); }
.wcb .wcb-stage.grid .cell.r-grey { background: repeating-linear-gradient(135deg, rgba(42, 40, 36, 0.24) 0 1px, var(--paper) 1px 7px); }
.wcb .wcb-stage.grid .cell.r-no { background: var(--paper); }
.wcb .wcb-stage.grid .cell.r-notvalid {
    background:
        linear-gradient(to top right, transparent calc(50% - 0.7px), var(--ink) calc(50% - 0.7px) calc(50% + 0.7px), transparent calc(50% + 0.7px)),
        linear-gradient(to bottom right, transparent calc(50% - 0.7px), var(--ink) calc(50% - 0.7px) calc(50% + 0.7px), transparent calc(50% + 0.7px)),
        var(--paper);
}
.wcb-stage.grid .cell.r-notvalid .cell-name { text-decoration: line-through; }


/* ---------- summary and the way down to the checker ---------- */

.wcb-summary {
    max-width: 720px;
    margin: 2.5rem auto 0;
    font-family: 'Fraunces', serif;
    font-style: italic;
    font-size: clamp(1.05rem, 1.7vw, 1.3rem);
    line-height: 1.55;
    text-align: center;
}

.wcb .wcb-next {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    margin: 2.5rem auto 0;
    color: var(--ink);
    text-decoration: none;
    text-align: center;
}
.wcb-next i {
    display: grid;
    place-items: center;
    width: 3rem;
    height: 3rem;
    border: 1px solid var(--ink);
    border-radius: 50%;
    font-style: normal;
    font-size: 1.3rem;
    animation: wcb-bob 1.8s ease-in-out infinite;
}
.wcb-next span { font-size: 0.95rem; }

@keyframes wcb-bob { 0%, 100% { transform: none; } 50% { transform: translateY(6px); } }



/* ---------- one place: the answer right below the cell ---------- */

.cell-detail {
    position: absolute;
    z-index: 6;
    padding: 1rem 1.1rem;
    overflow: hidden;
    background: var(--paper);
    color: var(--ink);
    border: 1px solid var(--ink);
    box-shadow: 0 10px 26px rgba(42, 40, 36, 0.28);
    font-size: 0.86rem;
    line-height: 1.45;
    transition: height 0.35s ease, opacity 0.3s ease;
}
.cd-title { display: block; margin-right: 2.6rem; font-family: 'Cinzel', serif; font-size: 1.1rem; letter-spacing: 0.04rem; }
.cell-detail dl { margin-top: 0.6rem; }
.cell-detail dl div { padding: 0.35rem 0; border-top: 1px solid var(--line); }
.cell-detail dt { font-size: 0.62rem; letter-spacing: 0.12rem; text-transform: uppercase; opacity: 0.6; }
.cell-detail dd { margin-top: 0.1rem; display: flex; align-items: center; }
.cd-why { margin-top: 0.6rem; font-family: 'Fraunces', serif; font-style: italic; font-size: 0.98rem; }
.cd-note { margin-top: 0.5rem; padding: 0.35rem 0.6rem; border: 1px dashed var(--ink); font-size: 0.8rem; }
.cd-last { margin-top: 0.6rem; padding-top: 0.5rem; border-top: 1px solid var(--ink); font-weight: 500; }
.cd-last a { color: inherit; }

.wcb .cell-detail .cd-x {
    position: absolute;
    top: 0.7rem;
    right: 0.7rem;
    width: 2rem;
    height: 2rem;
    border: 1px solid var(--ink);
    border-radius: 50%;
}
.cd-x span { position: absolute; top: 50%; left: 50%; width: 0.8rem; height: 1px; background: var(--ink); }
.cd-x span:first-child { transform: translate(-50%, -50%) rotate(45deg); }
.cd-x span:last-child { transform: translate(-50%, -50%) rotate(-45deg); }
.cd-x:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

/* inside a Systems row: the bar runs the width of the sheet, not the window */
.sheet .wcb-bar { box-shadow: none; clip-path: none; margin-left: -1.2rem; margin-right: -1.2rem; padding-left: 1.2rem; padding-right: 1.2rem; }


/* ---------- phone ---------- */

@media (max-width: 760px) {
    .doors { grid-template-columns: minmax(0, 1fr); }
    .wcb .door { min-height: 0; display: grid; grid-template-columns: 5rem minmax(0, 1fr); column-gap: 1rem; align-items: start; }
    .door-pic { grid-row: span 3; width: 5rem; margin: 0; }
    .wcb-bar { position: static; }
    .wcb-count { margin-left: 0; width: 100%; }
    .wcb-stage.section .cell-name { font-size: 0.58rem; white-space: normal; line-height: 1.15; }
    .wcb-stage.section .cell .pic { max-height: 1.9rem; }
    .wcb-stage.section .cell-rule span,
    .wcb-stage.section .cell-note { display: none; }
    .wcb-stage.section .cell { padding: 0.15rem; gap: 0.05rem; }
    .slabel { font-size: 0.56rem; letter-spacing: 0.12rem; }
}


/* ---------- reduced motion: everything is just there ---------- */

@media (prefers-reduced-motion: reduce) {
    .wcb * { animation: none !important; transition: none !important; }
    .wcb-bg .layer { opacity: 1; }
    .wcb .cell { opacity: 1; transform: none; }
    .wcb-next i { animation: none; }
}
